home *** CD-ROM | disk | FTP | other *** search
/ L' Effet Pommier 3 / L'Effet Pommier - Volume 03.iso / Graphismes / Bitmap / NIH Image 1.59 / Macros / Image Macros < prev    next >
Text File  |  1993-10-07  |  2KB  |  97 lines

  1. {
  2. This file contains contains example macros written in Image's
  3. Pascal-like programming language. These macros will automatically
  4. be loaded when Image is launched as long as this file is in the same folder
  5. as Image, or in the System folder, and it has the name 'Image Macros'.
  6. }
  7.  
  8. macro 'Measure [1]'       begin Measure end;
  9. macro 'Show Results [2]'  begin ShowResults end;
  10. macro 'Reset [3]'         begin ResetCounters end;
  11. macro 'Copy Results [4]'  begin CopyResults end;
  12. macro 'Start Capture [G]' begin StartCapturing end;
  13.  
  14.  
  15. Macro 'Draw Arrow [A]'
  16. {Draws an arrow based on the current straight line selection.}
  17. var
  18.   size,angle,dx,dy,pi,theta:real;
  19.   x1,y1,x2,y2,LineWidth,width,height:integer;
  20. begin
  21.   size:=12;  {pixels}
  22.   angle:=20; {degrees}
  23.   pi:=3.14159;
  24.   GetLine(x1,y1,x2,y2,LineWidth);
  25.   if x1<0 then begin
  26.     PutMessage('Use the line tool(straight) to select a line first.');
  27.     exit;
  28.   end;
  29.   MoveTo(x1,y1);
  30.   LineTo(x2,y2);
  31.   KillRoi;
  32.   GetPicSize(width,height);
  33.   y1:=height-y1;
  34.   y2:=height-y2;
  35.   if LineWidth>1 then size:=size*LineWidth*0.5;
  36.   angle:=(angle/180)*pi;
  37.   dx:=x1-x2;
  38.   dy:=y1-y2;
  39.   if dx=0 then begin
  40.     if dy>=0 then theta:=pi/2 else theta:=3/2*pi
  41.   end else begin
  42.     theta:=arctan(dy/dx);
  43.     if dx<0 then theta:=theta+pi;
  44.   end;
  45.   moveto(x2,height-y2);
  46.   lineto(x2+size*cos(theta+angle),height-(y2+size*sin(theta+angle)));
  47.   moveto(x2,height-y2);
  48.   lineto(x2+size*cos(theta-angle),height-(y2+size*sin(theta-angle)));
  49. end;
  50.  
  51.  
  52. macro 'Print All';
  53. {Use SetOption, which turns off halftoning, for better quality}
  54. {(and faster) printing of binary pictures.}
  55. var
  56.   i:integer;
  57. begin
  58.   for i:=1 to nPics do begin
  59.      SelectPic(i);
  60.      {SetOption;}
  61.      Print;
  62.   end;
  63. end;
  64.  
  65.  
  66. macro '(-' begin end;
  67.  
  68.  
  69. macro 'Make Step Function';
  70. {Generates a grayscale step function within the current selection.}
  71. var
  72.   left,top,width,height,nSteps,StepSize,i,x:integer;
  73.   value:real;
  74. begin
  75.   GetRoi(left,top,Width,Height);
  76.   if width=0 then begin
  77.     PutMessage('This macro requires a rectangular selection.');
  78.     Exit;
  79.   end;
  80.   SaveState;
  81.   nSteps:=GetNumber('Number of steps',16);
  82.   value:=255;
  83.   StepSize:=width div nSteps;
  84.   x:=left;
  85.   for i:=1 to nSteps do begin
  86.     MakeRoi(x,top,StepSize,Height);
  87.     SetForeground(round(value));
  88.     fill;
  89.     x:=x+StepSize;
  90.     value:=value-256/nSteps;
  91.   end;
  92.   KillRoi;
  93.   RestoreState;
  94. end;
  95.  
  96.  
  97.